# -*- coding: utf-8 -*-

from utils.operators.spark_submit import SparkSubmitOperator
from jms.ods.tab import jms_ods__tab_barscan_collect, jms_ods__tab_barscan_sign, jms_ods__tab_barscan_deliver
from jms.ods.tab import jms_ods__tab_aviation_send_record, jms_ods__tab_send_goods_report, jms_ods__tab_take_delivery

jms_dm__dm_cn_export_flight_time_analyse_dt = SparkSubmitOperator(
    task_id='jms_dm__dm_cn_export_flight_time_analyse_dt',
    pool_slots=4,
    task_concurrency=1,  # 如果任务不支持并发，则将 task_concurrency 设为 1
    name='jms_dm__dm_cn_export_flight_time_analyse_dt_{{ execution_date | date_add(-4) | cst_ds }}',  # yarn 任务名称
    driver_memory='4G',
    executor_memory='8G',
    executor_cores=4,
    num_executors=10,
    email=['shenjiaming@jtexpress.com','yl_bigdata@yl-scm.com'],
    conf={'spark.executor.memoryOverhead': 2048,
          'spark.core.connection.ack.wait.timeout': 3000,
          'spark.default.parallelism': 600,
          'spark.locality.wait': 60,
          'spark.driver.maxResultSize': 20,
          },
    java_class='com.yunlu.bigdata.jobs.export.ExportFlightTimeAnalyse',  # spark 主类
    application='hdfs:///scheduler/jms/spark/lyx/flight_time_analyse/jobs-1.0-SNAPSHOT-jar-with-dependencies.jar',
    # spark jar 包
    application_args=['{{ execution_date | date_add(-4) | cst_ds }}'],
    # 参数dt 2020-10-26
)

# 设置依赖
jms_dm__dm_cn_export_flight_time_analyse_dt << [
    jms_ods__tab_barscan_collect,
    jms_ods__tab_barscan_sign,
    jms_ods__tab_barscan_deliver,
    jms_ods__tab_aviation_send_record,
    jms_ods__tab_send_goods_report,
    jms_ods__tab_take_delivery
]
